home *** CD-ROM | disk | FTP | other *** search
/ Explorer - Mosaic & Web / Explorer - Mosaic & Web.iso / helpers / ghostvew / src / gvcdisp.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-08-01  |  17.6 KB  |  685 lines

  1. /* Copyright (C) 1993, 1994, Russell Lang.  All rights reserved.
  2.   
  3.   This file is part of GSview.
  4.   
  5.   This program is distributed with NO WARRANTY OF ANY KIND.  No author
  6.   or distributor accepts any responsibility for the consequences of using it,
  7.   or for whether it serves any particular purpose or works at all, unless he
  8.   or she says so in writing.  Refer to the GSview Free Public Licence 
  9.   (the "Licence") for full details.
  10.   
  11.   Every copy of GSview must include a copy of the Licence, normally in a 
  12.   plain ASCII text file named LICENCE.  The Licence grants you the right 
  13.   to copy, modify and redistribute GSview, but only under certain conditions 
  14.   described in the Licence.  Among other things, the Licence requires that 
  15.   the copyright notice and this notice be preserved on all copies.
  16. */
  17.  
  18. /* gvcdisp.c */
  19. /* Display GSview routines common to Windows and PM */
  20. #ifdef _Windows
  21. #include "gvwin.h"
  22. #else
  23. #include "gvpm.h"
  24. #endif
  25.  
  26. FILE *debug_file;
  27.  
  28. void
  29. gs_puts(char *str, FILE *f)
  30. {
  31.     fputs(str, f);
  32.     if (debug_file != (FILE *)NULL)
  33.        fputs(str, debug_file);
  34. }
  35.  
  36. void 
  37. gs_copy(FILE *from, FILE *to, long begin, long end)
  38. {
  39.     dsc_copy(from, to, begin, end, NULL);
  40.     if (debug_file != (FILE *)NULL)
  41.        dsc_copy(from, debug_file, begin, end, NULL);
  42. }
  43.  
  44. /* transform cursorpos from coordinates relative to bottom left
  45.  * corner of paper to bottom left corner of rotated coordinate
  46.  * system
  47.  */
  48. void
  49. transform_cursorpos(float *x, float *y)
  50. {
  51. float oldx, oldy;
  52. int real_orientation;
  53. int width, height;
  54.     oldx = *x;
  55.     oldy = *y;
  56.     width  = (unsigned int)(display.width  * 72.0 / option.xdpi);
  57.     height = (unsigned int)(display.height * 72.0 / option.ydpi);
  58.     real_orientation = option.orientation;
  59.     if (option.swap_landscape) {
  60.         if (option.orientation == IDM_LANDSCAPE)
  61.         real_orientation = IDM_SEASCAPE;
  62.         else if (option.orientation == IDM_SEASCAPE)
  63.         real_orientation = IDM_LANDSCAPE;
  64.     }
  65.     switch (real_orientation) {
  66.         case IDM_PORTRAIT:
  67.         break;
  68.         case IDM_LANDSCAPE:
  69.             *x = height - oldy;
  70.             *y = oldx;
  71.             break;
  72.         case IDM_UPSIDEDOWN:
  73.             *x = width - oldx;
  74.             *y = height - oldy;
  75.         break;
  76.         case IDM_SEASCAPE:
  77.             *x = oldy;
  78.             *y = width - oldx;
  79.             break;
  80.     }
  81.     return;
  82. }
  83.  
  84. /* get current media index to paper_size[], or -1 if no match */
  85. int
  86. get_paper_size_index(void)
  87. {
  88. int i;
  89.     for (i=0; paper_size[i].name != (char *)NULL; i++) {
  90.         if (!stricmp(paper_size[i].name, option.medianame))
  91.         return i;
  92.     }
  93.     return -1;
  94. }
  95.  
  96. /* calculate bitmap size for gs */
  97. void
  98. gs_size(void)
  99. {
  100. int i = get_paper_size_index();
  101.     if ( (option.xdpi == 0.0) || (option.ydpi == 0.0) )
  102.         option.xdpi = option.ydpi = DEFAULT_RESOLUTION;
  103.     display.epsf_clipped = FALSE;
  104.     switch (option.orientation) {
  105.         case IDM_LANDSCAPE:
  106.         case IDM_SEASCAPE:
  107.         if (i < 0) {
  108.             display.width = option.user_height;
  109.             display.height = option.user_width;
  110.         }
  111.         else {
  112.             display.width = paper_size[i].height;
  113.             display.height = paper_size[i].width;
  114.         }
  115.         break;
  116.         default:
  117.         if ((doc != (PSDOC *)NULL) && doc->epsf
  118.             && option.epsf_clip) {
  119.             display.epsf_clipped = TRUE;
  120.             display.width = doc->bbox.urx - doc->bbox.llx;
  121.             display.height = doc->bbox.ury - doc->bbox.lly;
  122.         }
  123.         else if (i < 0) {
  124.             display.width = option.user_width;
  125.             display.height = option.user_height;
  126.         }
  127.         else {
  128.             display.width = paper_size[i].width;
  129.             display.height = paper_size[i].height;
  130.         }
  131.     }
  132.     display.width  = (unsigned int)(display.width  / 72.0 * option.xdpi);
  133.     display.height = (unsigned int)(display.height / 72.0 * option.ydpi);
  134. }
  135.  
  136. /* change the size of the gs image if open */
  137. void
  138. gs_resize(void)
  139. {
  140.     gs_size();
  141.     if (!gsprog.valid)
  142.         return;
  143.     if ( (psfile.file == (FILE *)NULL) && (doc != (PSDOC *)NULL) )
  144.         dfreopen();
  145.  
  146.     if (option.redisplay && display.page && (doc != (PSDOC *)NULL))
  147.         display.do_display = TRUE;
  148.  
  149.     gsview_endfile();
  150.     display.do_resize = TRUE;
  151. }
  152.  
  153. void
  154. gs_magnify(float scale)
  155. {
  156. int xtemp, ytemp;
  157.     xtemp = (int)(option.xdpi * scale + 0.5);
  158.     ytemp = (int)(option.ydpi * scale + 0.5);
  159.     if ( (xtemp == option.xdpi) && (scale > 1.0) ) {
  160.         option.xdpi++;    /* force magnification if requested */
  161.         option.ydpi++;
  162.     }
  163.     else {
  164.         option.xdpi = xtemp;
  165.         option.ydpi = ytemp;
  166.     }
  167.     dfreopen();
  168.     gs_resize();
  169.     zoom = FALSE;
  170.     dfclose();
  171. }
  172.  
  173. void
  174. gsview_orientation(int new_orientation)
  175. {
  176.     if (new_orientation == option.orientation)
  177.         return;
  178.     if (new_orientation == IDM_SWAPLANDSCAPE) {
  179.         option.swap_landscape = !option.swap_landscape;
  180.         if (option.swap_landscape) 
  181.             check_menu_item(IDM_ORIENTMENU, IDM_SWAPLANDSCAPE, TRUE);
  182.         else
  183.             check_menu_item(IDM_ORIENTMENU, IDM_SWAPLANDSCAPE, FALSE);
  184.         if ((option.orientation != IDM_LANDSCAPE) && (option.orientation != IDM_SEASCAPE))
  185.             return;
  186.     }
  187.     else {
  188.         check_menu_item(IDM_ORIENTMENU, option.orientation, FALSE);
  189.         option.orientation = new_orientation;
  190.         check_menu_item(IDM_ORIENTMENU, option.orientation, TRUE);
  191.     }
  192.     gs_resize();
  193.         zoom = FALSE;
  194.     return;
  195. }
  196.  
  197. void
  198. gsview_media(int new_media)
  199. {
  200.     if ( (new_media == option.media) && (new_media != IDM_USERSIZE) )
  201.         return;
  202.     check_menu_item(IDM_MEDIAMENU, option.media, FALSE);
  203.     option.media = new_media;
  204.     check_menu_item(IDM_MEDIAMENU, option.media, TRUE);
  205.     get_menu_string(IDM_MEDIAMENU, option.media, option.medianame, sizeof(option.medianame));
  206.     gs_resize();
  207.         zoom = FALSE;
  208.     return;
  209. }
  210.  
  211. void
  212. gsview_unit(int new_unit)
  213. {
  214.     check_menu_item(IDM_UNITMENU, option.unit, FALSE);
  215.     option.unit = new_unit;
  216.     check_menu_item(IDM_UNITMENU, option.unit, TRUE);
  217.     info_wait(FALSE);
  218.     return;
  219. }
  220.  
  221. void
  222. gsview_endfile()
  223. {
  224.     if (!gsprog.valid)
  225.         return;
  226.     if (!option.quick ||
  227.              ((doc == (PSDOC *)NULL) && !is_pipe_done())) {
  228.         gs_close();
  229.         return;
  230.     }
  231.  
  232.     if (display.page)
  233.         next_page();
  234.  
  235.     display.do_endfile = TRUE;
  236.     psfile.previous_was_dsc = (doc != (PSDOC *)NULL) && doc->pages;
  237.     if (psfile.previous_was_dsc) {
  238.         strcpy(psfile.previous_name, psfile.name);
  239.         psfile.previous_begintrailer = doc->begintrailer;
  240.         psfile.previous_endtrailer = doc->endtrailer;
  241.     }
  242.     else {
  243.         psfile.previous_name[0] = '\0';
  244.         psfile.previous_begintrailer = 0;
  245.         psfile.previous_endtrailer = 0;
  246.     }
  247.  
  248. }
  249.  
  250. /* open a new document */
  251. void
  252. gsview_openfile(char *filename)
  253. {
  254. int i;
  255.     load_string(IDS_WAITREAD, szWait, sizeof(szWait));
  256.     info_wait(TRUE);
  257.     psfile.pagenum = 1;
  258.     page_extra = 0;
  259.     if (dsc_scan(filename)) {
  260.         /* found DSC comments */
  261.         if (doc->orientation == PORTRAIT)
  262.         gsview_orientation(IDM_PORTRAIT);
  263.         if (doc->orientation == LANDSCAPE)
  264.         gsview_orientation(IDM_LANDSCAPE);
  265.         if (doc->default_page_media) {
  266.         char thismedia[20];
  267.         for (i=IDM_LETTER; i<IDM_USERSIZE; i++) {
  268.             get_menu_string(IDM_MEDIAMENU, i, thismedia, sizeof(thismedia));
  269.             if (!stricmp(thismedia, doc->default_page_media->name)) {
  270.                 gsview_media(i);
  271.                 break;
  272.             }
  273.         }
  274.         if (i == IDM_USERSIZE) {
  275.             gsview_media(IDM_USERSIZE);
  276.             option.user_width  = doc->default_page_media->width;
  277.             option.user_height = doc->default_page_media->height;
  278.         }
  279.         }
  280.     }
  281. }
  282.  
  283.  
  284. /* get filename then open new file for printing or extract */
  285. void 
  286. gsview_select()
  287. {
  288. char buf[MAXSTR];
  289.     strcpy(buf, previous_filename);
  290.     if (get_filename(buf, FALSE, FILTER_PS, 0, IDS_TOPICOPEN))
  291.         gsview_selectfile(buf);
  292. }
  293.  
  294. /* open new file for printing or extract */
  295. void
  296. gsview_selectfile(char *filename)
  297. {
  298.     if (gsprog.valid)
  299.         gsview_endfile();
  300.     while (*filename && *filename==' ')
  301.          filename++;
  302.     gsview_openfile(filename);
  303.     strcpy(previous_filename, filename);
  304.     info_wait(FALSE);
  305. }
  306.  
  307. /* get filename then open a new document and display it */
  308. void 
  309. gsview_display()
  310. {
  311. char buf[MAXSTR];
  312.     strcpy(buf, previous_filename);
  313.     if (get_filename(buf, FALSE, FILTER_PS, 0, IDS_TOPICOPEN))
  314.         gsview_displayfile(buf);
  315. }
  316.  
  317. /* open a new document and display it */
  318. void
  319. gsview_displayfile(char *filename)
  320. {
  321.     gsview_endfile();
  322.     gsview_openfile(filename);
  323.     strcpy(previous_filename, filename);
  324.     if (display.epsf_clipped || ((doc != (PSDOC *)NULL) 
  325.         && doc->epsf && option.epsf_clip))
  326.         gs_resize();
  327.     display.do_display = TRUE;
  328. }
  329.  
  330.  
  331. /* add Ghostscript code to change orientation */
  332. void
  333. fix_orientation(FILE *f)
  334. {
  335. int real_orientation;
  336. char buf[MAXSTR];
  337.     /* save interpreter state */
  338.     gs_puts("clear cleardictstack save /gsview_save exch def\r\n",f);
  339.     display.saved = TRUE;
  340.     /* provide zoom or epsf offset */
  341.         if (zoom) {
  342.         sprintf(buf,"/gsview_offset {%d %d translate} def\r\n",
  343.             -display.zoom_xoffset, -display.zoom_yoffset);
  344.     }
  345.     else if (display.epsf_clipped)
  346.         sprintf(buf,"/gsview_offset {%d %d translate} def\r\n",
  347.             -doc->bbox.llx, -doc->bbox.lly);
  348.     else
  349.         sprintf(buf,"/gsview_offset {} def\r\n");
  350.     gs_puts(buf, f);
  351.     real_orientation = option.orientation;
  352.     if (option.swap_landscape) {
  353.         if (option.orientation == IDM_LANDSCAPE)
  354.         real_orientation = IDM_SEASCAPE;
  355.         else if (option.orientation == IDM_SEASCAPE)
  356.         real_orientation = IDM_LANDSCAPE;
  357.     }
  358.     sprintf(buf,"/gsview_landscape  %s def\r\n",
  359.         real_orientation == IDM_LANDSCAPE ? "true" : "false");
  360.     gs_puts(buf, f);
  361.     sprintf(buf,"/gsview_upsidedown %s def\r\n",
  362.         real_orientation ==  IDM_UPSIDEDOWN ? "true" : "false");
  363.     gs_puts(buf, f);
  364.     sprintf(buf,"/gsview_seascape   %s def\r\n",
  365.         real_orientation == IDM_SEASCAPE ? "true" : "false");
  366.     gs_puts(buf, f);
  367.     sprintf(buf,"/gsview_zoom %s def\r\n", zoom ? "true" : "false");
  368.     gs_puts(buf, f);
  369.     send_prolog(f, IDR_ORIENT);
  370.     if (option.epsf_warn)
  371.         send_prolog(f, IDR_EPSFWARN);
  372. }
  373.  
  374. /* Create and open a scratch file with a given name prefix. */
  375. /* Write the actual file name at fname. */
  376. FILE *
  377. gp_open_scratch_file(const char *prefix, char *fname, const char *mode)
  378. {    char *temp;
  379.     if ( (temp = getenv("TEMP")) == NULL )
  380.         _getcwd(fname, MAXSTR);
  381.     else
  382.         strcpy(fname, temp);
  383.  
  384.     /* Prevent X's in path from being converted by mktemp. */
  385.     for ( temp = fname; *temp; temp++ ) {
  386.         *temp = (char)tolower(*temp);
  387.         if (*temp == '/')
  388.             *temp = '\\';
  389.     }
  390.     if ( strlen(fname) && (fname[strlen(fname)-1] != '\\') )
  391.         strcat(fname, "\\");
  392.  
  393.     strcat(fname, prefix);
  394.     strcat(fname, "XXXXXX");
  395.     mktemp(fname);
  396.     return fopen(fname, mode);
  397. }
  398.  
  399. /* reopen psfile */
  400. /* if psfile time/date or length has changed, kill gs and rescan the file */
  401. BOOL
  402. dfreopen()
  403. {
  404.     if (doc == (PSDOC *)NULL)
  405.         return TRUE;
  406.     dfclose();
  407.     if (psfile.name[0] == '\0')
  408.         return TRUE;
  409.     if ( (psfile.file = fopen(psfile.name, "rb")) == (FILE *)NULL ) {
  410.         if (debug)
  411.         message_box("dfreopen: file missing",0);
  412.         psfile.name[0] = '\0';
  413.         return FALSE;
  414.     }
  415.     if (psfile_changed()) {
  416.         if (debug)
  417.         message_box("dfreopen: file changed",0);
  418.         /* file may have changed beyond recognition so we must kill gs */
  419.         gs_close();
  420.         if (dsc_scan(psfile.name))
  421.             if ( (psfile.file = fopen(psfile.name, "rb")) == (FILE *)NULL ) {
  422.                 psfile.name[0] = '\0';
  423.                 return FALSE;
  424.             }
  425.     }
  426.     return TRUE;
  427. }
  428.  
  429. void
  430. dfclose()
  431. {
  432.     if (psfile.file != (FILE *)NULL)
  433.         fclose(psfile.file);
  434.     psfile.file = (FILE *)NULL;
  435. }
  436.  
  437. /* scan file for PostScript Document Structuring Conventions */
  438. /* return TRUE if valid DSC comments found */
  439. BOOL
  440. dsc_scan(char *filename)
  441. {
  442.     strcpy(psfile.name, filename);
  443.     dfclose();
  444.     if ( (psfile.file = fopen(psfile.name, "rb")) == (FILE *)NULL ) {
  445.         psfile.name[0] = '\0';
  446.         return FALSE;
  447.     }
  448.     psfile_savestat();
  449.     if (page_list.select)
  450.         free(page_list.select);
  451.     page_list.select = NULL;
  452.     if (doc)
  453.         dsc_scan_clean(doc);
  454.     psfile.preview = 0;
  455.     if (option.ignore_dsc)
  456.         doc = (PSDOC *)NULL;
  457.     else 
  458.         doc = dsc_scan_file(psfile.file);
  459.     if (doc == (PSDOC *)NULL) {
  460.         dfclose();
  461.         return FALSE;
  462.     }
  463.     if (doc->doseps) {
  464.         if (doc->doseps->tiff_begin)
  465.         psfile.preview = IDS_EPST;
  466.         if (doc->doseps->mf_begin)
  467.         psfile.preview = IDS_EPSW;
  468.     }
  469.     if (!psfile.preview && (doc->beginpreview != doc->endpreview))
  470.         psfile.preview = IDS_EPSI;
  471.     page_list.select = (BOOL *)malloc( doc->numpages * sizeof(BOOL) );
  472.     return TRUE;
  473. }
  474.  
  475.  
  476.  
  477. /* Copy specified pages from psfile.file to file f */
  478. void
  479. dsc_getpages(FILE *f, int first, int last)
  480. {
  481. int i, page;
  482. char buf[MAXSTR];
  483.     for (i=first-1; i<last; i++) {
  484.         page = map_page(i);
  485.         if (doc->pages) {
  486.             sprintf(buf,"(Page: %s %d\\n) print flush\r\n", doc->pages[page].label ? doc->pages[page].label : " ", page+1);
  487.         gs_puts(buf, f);
  488.         gs_copy(psfile.file, f, doc->pages[page].begin, doc->pages[page].end);
  489.         }
  490.         else {
  491.             sprintf(buf,"(Page: %d\\n) print flush\r\n",page); 
  492.         gs_puts(buf, f);
  493.         gs_copy(psfile.file, f, doc->endsetup, doc->endtrailer);
  494.         }
  495.     }
  496. }
  497.  
  498.  
  499. /* Copy dsc header to file f */
  500. void
  501. dsc_header(FILE *f)
  502. {
  503. char *p, *d;
  504. char buf[MAXSTR];
  505.     d = buf;
  506.     gs_puts("(Displaying ",f);
  507.     for (p=psfile.name; *p; p++) {
  508.         if (*p != '\\')
  509.         *d++ = *p;
  510.         else
  511.             *d++ = '/';
  512.     }
  513.     *d = '\0';
  514.     gs_puts(buf, f);
  515.     gs_puts("\\n) print flush\r\n", f);
  516.     gs_copy(psfile.file, f, doc->begincomments, doc->endcomments);
  517.     gs_copy(psfile.file, f, doc->begindefaults, doc->enddefaults);
  518.     gs_copy(psfile.file, f, doc->beginprolog, doc->endprolog);
  519.     gs_copy(psfile.file, f, doc->beginsetup, doc->endsetup);
  520. }
  521.  
  522.  
  523. /* Send commands to gs to display page */
  524. void
  525. dsc_dopage(void)
  526. {
  527.     load_string(IDS_WAITDRAW, szWait, sizeof(szWait));
  528.     info_wait(TRUE);
  529.     display.do_display = TRUE;
  530. }
  531.  
  532. /* skip pages */
  533. void
  534. dsc_skip(int skip)
  535. {
  536.     if ( (skip == 0)
  537.       || ((skip > 0) && (psfile.pagenum == doc->numpages))
  538.       || ((skip < 0) && (psfile.pagenum == 1))
  539.       || (doc->numpages == 0) ) {
  540.         play_sound(SOUND_NOPAGE);
  541.         info_wait(FALSE);
  542.         return;
  543.     }
  544.     psfile.pagenum += skip;
  545.     if (psfile.pagenum > (int)doc->numpages)
  546.          psfile.pagenum = doc->numpages;
  547.     if (psfile.pagenum < 1)
  548.         psfile.pagenum = 1;
  549.     load_string(IDS_WAIT, szWait, sizeof(szWait));
  550.     info_wait(TRUE);
  551.     if (display.page)
  552.         next_page();
  553.     if (gs_open())
  554.         dsc_dopage();
  555. }
  556.  
  557. /* reverse zero based page number if needed */
  558. int
  559. map_page(int page)
  560. {
  561.         if (doc->pageorder == DESCEND) 
  562.         return (doc->numpages - 1) - page;
  563.     return page;
  564. }
  565.  
  566. /* Send necessary output to display Ghostscript */
  567. /* This must not be called from thread 1 because it is lengthy */
  568. /* Functions called from here must NOT create windows since this */
  569. /* thread does not have an anchor block or message queue */
  570. /* returns TRUE if OK, FALSE if aborted */
  571. BOOL
  572. do_output()
  573. {
  574.     char *p, *d;
  575.     char debug_filename[MAXSTR];
  576.     char buf[256];
  577.  
  578.     if (debug_file != (FILE *)NULL)
  579.     fclose(debug_file);
  580.     if (debug)
  581.         debug_file = gp_open_scratch_file(szScratch, debug_filename, "wb");
  582.  
  583.     if (gsprog.valid && display.page)
  584.     next_page();
  585.  
  586. #ifndef GS261
  587.     /* Cause a GS_BEGIN message to be sent to GSview */
  588. /*    gs_puts("(Begin\n) print flush\r\n", gsprog.input); */
  589.     gs_puts("-1 false .outputpage\r\n", gsprog.input);
  590. #endif
  591.  
  592.     if (display.do_endfile && gsprog.valid) {
  593.     if ((display.saved) && (psfile.previous_was_dsc)) {
  594.         /* send trailer if needed */
  595.         FILE *f;
  596.         if ( (f = fopen(psfile.previous_name, "rb")) != (FILE *)NULL ) {
  597.             gs_copy(f, gsprog.input, psfile.previous_begintrailer, psfile.previous_endtrailer);
  598.         fclose(f);
  599.         }
  600.     }
  601.     if (display.saved) {
  602.         /* restore interpreter state */
  603.         gs_puts("gsview_cleanup\r\ngsview_save restore\r\n", gsprog.input);
  604.     }
  605.     else
  606.         gs_puts("clear cleardictstack\r\n", gsprog.input);
  607.     gs_puts("erasepage\r\n", gsprog.input); /* needed for documents that don't use showpage */
  608.     display.saved = FALSE;
  609.     }
  610.  
  611.     if (display.abort)
  612.     return FALSE;
  613.  
  614.     if (display.do_resize && gsprog.valid) {
  615.     sprintf(buf, "mark /HWSize [%u %u]\r\n",display.width,display.height);
  616.     gs_puts(buf, gsprog.input);
  617.     if (zoom)
  618.             sprintf(buf,"/HWResolution [%g %g]\r\n",option.zoom_xdpi,option.zoom_ydpi);
  619.         else
  620.             sprintf(buf,"/HWResolution [%g %g]\r\n",option.xdpi,option.ydpi);
  621.     gs_puts(buf, gsprog.input);
  622.         sprintf(buf,"currentdevice putdeviceprops pop initgraphics erasepage\r\n");
  623.     gs_puts(buf, gsprog.input);
  624.     }
  625.  
  626.     if (display.abort)
  627.     return FALSE;
  628.  
  629.     if (display.do_display) {
  630.     if (doc != (PSDOC *)NULL) {
  631.         /* found DSC comments */
  632.         if (!display.saved) {
  633.             fix_orientation(gsprog.input);
  634.             dsc_header(gsprog.input);
  635.         }
  636.             if (display.abort)
  637.             return FALSE;
  638.         dsc_getpages(gsprog.input,psfile.pagenum,psfile.pagenum);
  639.     }
  640.     else {
  641.         if (!display.saved) {
  642.             fix_orientation(gsprog.input);
  643.         }
  644.         /* non conformant file - send unmodified */
  645.         gs_puts("(Displaying ",gsprog.input);
  646.         d = buf;
  647.         for (p=psfile.name; *p; p++) {
  648.         if (*p != '\\')
  649.             *d++ = *p;
  650.         else
  651.             *d++ = '/';
  652.         }
  653.         *d = '\0';
  654.         gs_puts(buf, gsprog.input);
  655.         gs_puts("\\n) print flush\r\n",gsprog.input);
  656.         d = buf;
  657.         *d++ = '(';
  658.         for (p=psfile.name; *p; p++) {
  659.         if (*p != '\\')
  660.             *d++ = *p;
  661.         else
  662.             *d++ = '/';
  663.         }
  664.         *d = '\0';
  665.         gs_puts(buf, gsprog.input);
  666.         gs_puts(") run\r\n",gsprog.input);
  667.     }
  668.     }
  669.  
  670.     if (gsprog.valid)
  671.         gs_puts("flushpage\r\n",gsprog.input);
  672.     dfclose();
  673.     if (debug_file)
  674.         fclose(debug_file);
  675.     debug_file = (FILE *)NULL;
  676.  
  677. #ifndef GS261
  678.     /* Cause a GS_END message to be sent to GSview */
  679. /*    gs_puts("(End\n) print flush\r\n", gsprog.input); */
  680.     gs_puts("-2 false .outputpage\r\n", gsprog.input);
  681. #endif
  682.  
  683.     return TRUE;    /* all done */
  684. }
  685.